#ifndef MASTER_H
#define MASTER_H

#include <string>
#include <cassert>
#include "BaseGameEntity.h"
#include "Locations.h"
#include "MasterOwnedStates.h"
#include "StateMachine.h"
using namespace std;
//#include "State.h" //May Need to add it if errors appear - K13


//cim = const int Master
const int cimDiscomfortFlag    = 5; //Above this and Master is Uncomfortable
const int cimHungerFlag        = 5; //Above this and Master is Hungry
const int cimThirstFlag        = 5; //Above this and Master is Thirsty
const int cimFatigueFlag	   = 5; //Above this and Master is Tired     
const int cimPovertyFlag       = 0; //Equal to this and pockets are full


class Master : public BaseGameEntity
{
private:

  State<Master>*			pCurrentState;	//Holds Master's State

  location_type				Location;		//Holds Master's Location

  int		iThirst;		//Higher == Thirstier
  int		iHunger;		//Higher == Hungrier
  int		iFatigue;		//Higher == Tireder
  int		iDiscomfort;	//Higher == Uncomfortabler
  int		iPoverty;		//Higher == Poorer

  int		iHunted;

  string Message;
  string ApprenticeMessage;

public:
	//hacked this hardcore
	StateMachine<Master>*		pStateMachine;  //Holds Entire Master's State Machine

	Master(int id): BaseGameEntity(id),
					Location(Town),
					iThirst(0),
					iHunger(0),
					iFatigue(0),
					iDiscomfort(0),
					iPoverty(10)
	{
		pStateMachine = new StateMachine<Master>(this);
		pStateMachine->SetCurrentState(VisitTownAndWork::Instance());
	}

	~Master() { delete pStateMachine; }

	void FindActivity(); // Finds the next activity based on his needs.

	void Update();
	void ChangeState(State<Master>* pNewState); //also self explanatory

  //removed ChangeState from function as it should belong in the StateMachine
  StateMachine<Master>* GetFSM() const{return pStateMachine;}


  
  //What's this? - Strog	
  //Returns Current Location - K13
  location_type funcLocation()const{return Location;}
	

	//Should these all be declared if they're in MasterOwnedStates? - Strog
	//No, but I fixed it. - K13
	void    ChangeLocation(const location_type loc){Location=loc;}
    
	//I think that these bool functions should have "is" in front of the name. aka isFatigued() 
	//in order to make more sense - Strog
	bool    Fatigued();
	void    DecreaseFatigue(){iFatigue -= 1;} //Possibly Redundant - K13
	void    IncreaseFatigue(){iFatigue += 1;}

	bool	Thirsty(); 
	void	DecreaseThirst(){iThirst -=1;} //Possibly Redundant - K13
	void	IncreaseThirst(){iThirst +=1;}

	bool	Hungry();
	void	DecreaseHunger(){iHunger -=1;} //Possibly Redundant - K13
	void	IncreaseHunger(){iHunger +=1;}

	bool	Uncomfortable();
	void	DecreaseDiscomfort(){iDiscomfort -=1;}//Possibly Redundant - K13
	void	IncreaseDiscomfort(){iDiscomfort +=1;}

	bool	Wealthy();
	void	DonateMoney(){iPoverty = 10;}
	void	DecreasePoverty() {iPoverty -= 1; }

	int		HuntedCheck() {return iHunted;}
	void	SetHuntedCounter(int H) {iHunted = H;}

	void InputMessage(string M) {Message = M;}
	string OutPutMessage() {return Message;}
	void InputApprenticeMessage(string M) {ApprenticeMessage = M;}
	string OutputApprenticeMessage() {return ApprenticeMessage;}	
};

#endif
